function externalInit() {
	
	
	var dsmain = getDataset("todolists_TodoListVO");
	var appoveid = getParameter('approveid');
	var loader = new DatasetLoader(dsmain);
	if(appoveid != null ){
		dsmain.reqParameterMap = new HashMap();
		dsmain.reqParameterMap.put("pk_todolist",appoveid);
	}
	loader.load();
	
	/**
	 * 调用查询模版进行数据查询
	 *//*
	BillEventHandler.prototype.onBoQuery = function()
	{  	
		var url = getString(this.billUI.billController.queryTemplateUrl, getCorePath() + "/querytemplatecg.jsp?otherPageUniqueId=" + getPageUniqueId() + "&otherPageId=" + getPageId() + "&pageId=" + getPageId() + "_qt&befullname=" + this.getMasterDs().objMeta);
		showDialog(url , trans('ml_qrydialog'), "680", "450", "queryDialogId", false);
	};*/
	
	/*重写PFBillEventHandler*/
	PFBillEventHandler.prototype.returnFunForCheck = function(returnArg, isSuccess, returndoc){
		if(isSuccess){
			var oThis = returnArg[0], headDs = returnArg[1], action = returnArg[2];
			// 如果没有审批流指派，则直接通过，不弹出框
			if(returndoc == 'NOPF'){
				if(action == "commit"){
					billUI.eventHandler.JkbxSaveImpl(null);
				}else if(action == "approve"){
					oThis.commitAudit("", "approve");// 审批通过
				}
			}
			else{
				var paramArr = decodeURIComponent(returndoc).split('#');
				returndoc = paramArr[0];
				window.FlexControlParam = paramArr[1]; 
				
				var meta = headDs.metadata;
				var key = null;
				for(var i = 0, count = meta.length; i < count; i++){
					if(meta[i].isPrimaryKey){
						key = meta[i].key;
						break;
					}
				}	
				//如果有指派信息，则将指派信息放入window参数
				var haveAssign = "N";
				window.assignparams = null;
				if("NO_ASSIGN" != returndoc){
					window.assignparams = returndoc;
					haveAssign = "Y";
				}
				
				if(action == "commit"){
					if(returndoc == 'NO_ASSIGN')
						billUI.eventHandler.JkbxSaveImpl(null);
					else{
						var url = getCorePath() + "/assign/assign.jsp?pageId=assign"
								  + "&action=" + action
								  + "&rand=" + (Math.random()*10000).toString().substring(0, 4);
						showDialog(url , trans('ml_assigninfo'), "600", "500", "assignable_info_dialog", false,true);
					}
				}
				else if(action == "approve"){
					var billId = headDs.getValue(key);
					var billType = oThis.billUI.billController.billType;
					var url = getCorePath() + "/approve/approve.jsp?pageId=approve&billType=" + billType + "&billId=" 
							+ billId + "&haveAssign=" + haveAssign;
					showDialog(url , trans('ml_approvedialog'), "600", "450", "approveDialogId", false);
				}
			}
		}
	};

	
}

/**
 * 页面参数
 * @return 
 */
function setPageParamMap(key,value){
	if(window.PageParamMap == null)
		window.PageParamMap = new HashMap();
	window.PageParamMap.put(key,value);
}
function getPageParamByKey(key){
	if(window.PageParamMap != null)
		return window.PageParamMap.get(key);
}

function setToObject(key,value){
	window[key] = value;
}
function getFromObject(key){
	return window[key];
}
 
function setCheckManMap(key,value){
	if(window.CheckManMap == null)
		window.CheckManMap = new HashMap();
	window.CheckManMap.put(key,value);
}
function getCheckManByKey(key){
	if(window.CheckManMap != null)
		return window.CheckManMap.get(key);
}
function clearCheckManMap(){
	if(window.CheckManMap != null)
		window.CheckManMap.clear();
}



//联查审批情况
function selfDefBtnFuc(btnNo){   
	var ds = billUI.getEventHandler().getMasterDs();
	var row = ds.getSelectedRow();
	if(btnNo.name == 211){
		//联查审批情况
		
		if(row == null){
			showMessageDialog("请选择要联查的业务项！");
			return;
		}
		var billId = row.getCellValue(ds.nameToIndex("pk_todolist"))
		var billType = row.getCellValue(ds.nameToIndex("pk_billtype"));
		var url = getCorePath() + "/pfinfo/pfinfo.jsp?pageId=pfinfo&billId="+ billId +"&billType=" + billType + "&rand=" + (Math.random()*10000).toString().substring(0, 4);
		showDialog(url , "联查审批情况", "985", "450", "pfinfoDialog", true,true);
	}else if(btnNo.name == 203){
		var pk_todo_list = row.getCellValue(ds.nameToIndex('pk_todolist'));
		var url = getCorePath() + "/docmanage/docmanage.jsp?pageId=docmanage" 
				+ "&pk_jkbx=" + pk_todo_list
				+ "&rand=" + (Math.random()*10000).toString().substring(0, 4);
		showDialog(url , "文档管理", "550", "350", "attachmentDialog", true,true);
	}else if(btnNo.name == 202){
		var pk_todo_list = row.getCellValue(ds.nameToIndex('pk_todolist'));
		var billstatus = row.getCellValue(ds.nameToIndex('billstatus'));
		if(billstatus != 1){
			showMessageDialog("请审批通过之后进行操作!");
			return;
		}
		var drawOutCommand = new CommonCommand("sendOrder");
		var reqpara = "pk_todolist=" + pk_todo_list;
		drawOutCommand.setParameter(reqpara);
		drawOutCommand.setReturnFunc(showReturnValue);
		drawOutCommand.exec();

		// 当ajax请求成功后处理进度条和更新界面信息
		function showReturnValue(success) {
			if (success == 'ok') {
				// yanlei 保存成功
				// 显示资金申请单的卡片形式
				var pk_bx = row.getCellValue(ds.nameToIndex('pk_todolist'));
				if(pk_bx == null){
					showMessageDialog("生成资金申请单失败!");
					return;
				}
				
				var url = getCorePath() + "/bxmanageui.jsp?model=nc.lfw.finance.model.BxDJBasePageModel&ctrl=nc.lfw.finance.ctrl.BXManageController&delegator=nc.lfw.finance.delegator.BxDjDelegator&pageId=E01002XX07" 
						+ "&pk_bx=" + pk_bx + "&fromType=2648"
						+ "&rand=" + (Math.random()*10000).toString().substring(0, 4);
				showDialog(url , "资金申请单", "800", "600", "attachmentDialog", true,true);
				//showMessageDialog("生成成功,请到资金申请单进行查看!");
			} else if(success == 'isclosed'){
				showMessageDialog("事项单已关闭，无法生成资金申请单！");
			}else {
				showMessageDialog("调用失败");
			}
		}
	}
}

function getFromtype(){ 
	return "todolist";
}